Skip to content

feat: Checkbox 2.0 component - #4208

Merged
pomfrida merged 35 commits into
mainfrom
4191-update-checkbox-in-code
Jan 26, 2026
Merged

feat: Checkbox 2.0 component#4208
pomfrida merged 35 commits into
mainfrom
4191-update-checkbox-in-code

Conversation

@pomfrida

@pomfrida pomfrida commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

Summary

Implements Checkbox 2.0 using vanilla CSS, EDS foundation tokens, and Field component for layout and accessibility.

Changes

  • Field integration: Checkbox now uses <Field> internally for consistent layout and automatic accessibility
  • New props:
    • label - Label text (renders with Field.Label)
    • indicator - Shows "(Required)" or "(Optional)" after label (not exposed in storybook yet to have 1:1 on design)
    • helperMessage - Helper text below checkbox (auto-linked via aria-describedby) (same as above)

data-color-appearance defaults to accent

Features

  • Supports dark mode via data-color-scheme="dark"
  • Supports compact density via data-density="comfortable"
  • Accessible by default (aria-describedby, proper labeling)
  • 17 passing tests including a11y tests

Usage

// Basic
<Checkbox label="Accept terms" />

// Not yet documented in Storybook but is currently supporting following Field props:
<Checkbox 
  label="Accept terms" 
  helperMessage="You must accept the terms"
  data-color-appearance="danger" 
  indicator="(Required)"
/>

// Standalone (no label)
<Checkbox aria-label="Select row" />

Checklist

  • Tests pass (17 tests)
  • Storybook stories updated
  • Accessibility tested with jest-axe
  • Follows EDS 2.0 patterns (vanilla CSS, tokens, Field)

@pomfrida pomfrida self-assigned this Nov 5, 2025
@pomfrida pomfrida linked an issue Nov 5, 2025 that may be closed by this pull request
8 tasks
@pomfrida
pomfrida force-pushed the 4191-update-checkbox-in-code branch from d8807c9 to 9e5ed00 Compare November 11, 2025 10:22
@pomfrida
pomfrida force-pushed the 4191-update-checkbox-in-code branch from 43df467 to 7a34066 Compare November 18, 2025 11:37
@pomfrida
pomfrida force-pushed the 4191-update-checkbox-in-code branch 2 times, most recently from 10022a3 to 0f95852 Compare December 15, 2025 14:44
@pomfrida pomfrida changed the title feat: Checkbox 2.0 feat: Checkbox 2.0 [WIP] Dec 16, 2025
@pomfrida
pomfrida force-pushed the 4191-update-checkbox-in-code branch 2 times, most recently from a7f7a95 to bda4228 Compare January 14, 2026 15:26
- Checkbox now uses Field component for layout and accessibility
- Simplified API: removed labelProps and wrapperProps
- Added indicator prop for required/optional text
- Updated CSS with Figma design values (gap, padding, focus frame)
- Added Compact story to demonstrate density support
- Fixed Storybook preview to import correct CSS file
- Moved CSS entry point to next/index.css
- Checkbox now supports helperMessage for validation feedback
- Helper message automatically connected via aria-describedby
- Error state sets role='alert' on helper message for a11y
- Helper message color changes to red when error=true
- Added WithHelperMessage and updated ErrorState stories
- Added tests for helperMessage functionality
@pomfrida
pomfrida force-pushed the 4191-update-checkbox-in-code branch from 3e71157 to ed0b75d Compare January 19, 2026 12:59
- Removed error prop as it's not in the Figma design
- Users can use data-color-appearance attribute directly if needed
- Kept helperMessage for additional context
- Removed ErrorState story and related test
Shows how to use data-color-appearance='danger' for error styling
- Default to 'accent' color appearance for checkbox icon
- Allow override via data-color-appearance prop (e.g., 'danger')
- Helper message stays neutral by default, turns red for danger
- Add ColorAppearance type with valid values
- Add tests for color appearance functionality
@pomfrida pomfrida changed the title feat: Checkbox 2.0 [WIP] feat(eds-core-react): Checkbox 2.0 with Field integration Jan 19, 2026
@pomfrida pomfrida changed the title feat(eds-core-react): Checkbox 2.0 with Field integration feat: Checkbox 2.0 with Field integration Jan 19, 2026
… CSS

Token system handles data-color-appearance automatically via --eds-color-text-subtle
- Replace hardcoded pixel values with EDS tokens and future Figma token fallbacks
- Simplify CSS selectors by removing duplicates
- Move ColorAppearance type to shared types.ts
- Add data-density support for Table checkbox story
- Simplify helper message color logic (neutral for accent, follows color-appearance otherwise)
@pomfrida
pomfrida marked this pull request as ready for review January 19, 2026 14:57
Comment thread packages/eds-core-react/src/components/next/Checkbox/Checkbox.test.tsx Outdated
Comment thread packages/eds-core-react/src/components/next/Checkbox/checkbox.css Outdated
Icon component has two sizing modes:
1. Without size prop: uses font-size (1.5em) - affected by parent context
2. With size prop: uses density-aware tokens (--eds-sizing-icon-lg)

In table cells, the parent font-size is smaller (14px), causing icons
to shrink when using the font-size based approach.

By using size="lg", checkbox icons now consistently use design tokens:
- Spacious: 24px
- Comfortable: 20px

This also simplifies the CSS by removing manual width/height overrides.
Replaced padding-block + min-height with fixed height from density token.
This ensures comfortable density gets correct 24px height (was 32px due
to hardcoded 10px padding fallback designed for spacious mode).

Flexbox centers content vertically, so no padding needed.
- Remove WithIndicator story (indicator prop still supported via Field)
- Remove inline error message from form example (not relevant for checkbox)
- Remove data-density from TableCheckbox (uses default spacious)
Changed from opacity: 0.4 on teal to --eds-color-border-neutral-medium
(#aeaeae) to match Figma design exactly.

@eddiman eddiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but minor changes in which props should be exposed.

Comment thread packages/eds-core-react/src/components/next/Checkbox/Checkbox.types.ts Outdated
Comment thread packages/eds-core-react/src/components/next/Checkbox/checkbox.css Outdated
Comment thread packages/eds-core-react/src/components/next/Checkbox/checkbox.css Outdated
Comment thread packages/eds-core-react/src/components/next/Checkbox/checkbox.css
- Use data-selectable-space and data-space-proportions attributes
- Height now calculated from padding + content (matches Figma 'Hug')
- Spacious: 36px, Comfortable: 28px
- Clean up excessive comments in CSS
- Add comfortable density padding for standalone checkbox (28px)
- Spacious remains 36px (24px icon + 12px padding)
- Comfortable is 28px (20px icon + 8px padding)
- Clean up stories with dedicated WithoutVisibleLabel story
- Fix ColorSchemes story layout
- Update index.css layer order to match input branch
- Add argTypes with categorized props (Core, States, Field, Styling, HTML)
- Move className to input element via ...rest for consistency
- Remove data-color-appearance from public argTypes
- Update test to reflect className on input element
- Add Figma Code Connect file for design-code mapping
- Organize tests into descriptive describe blocks
- Fix import order in stories per conventions
- Remove redundant storyName annotations
- Enable and add snapshot test
@pomfrida
pomfrida requested a review from eddiman January 21, 2026 15:04
@pomfrida pomfrida changed the title feat: Checkbox 2.0 with Field integration feat: Checkbox 2.0 component Jan 21, 2026
Comment thread packages/eds-core-react/src/components/next/Checkbox/Checkbox.tsx Outdated
…Checkbox

- Hardcode color appearance to 'accent' per design requirements
- Remove data-color-appearance prop from types
- Remove related tests for overriding color appearance
Native disabled attribute already communicates disabled state to assistive technologies, making aria-disabled redundant on form controls.
@eddiman
eddiman self-requested a review January 22, 2026 08:23
eddiman
eddiman previously approved these changes Jan 22, 2026

@eddiman eddiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@eddiman
eddiman self-requested a review January 22, 2026 12:30
@pomfrida
pomfrida merged commit 6171f95 into main Jan 26, 2026
7 checks passed
@pomfrida
pomfrida deleted the 4191-update-checkbox-in-code branch January 26, 2026 08:57
This was referenced Jan 26, 2026
@github-actions github-actions Bot mentioned this pull request May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Checkbox in code

3 participants